package com.itboye.sunsun.utils;

import android.text.Spanned;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by itboye on 2017/3/25.
 */

public class UtilPhoneNum {
    public static ArrayList getNumber2(ArrayList list, Spanned content) {
        list = new ArrayList();
        Pattern p = Pattern.compile("\\d{3}-\\d{8}|\\d{4}-\\d{7}|\\d{11}");
        Matcher matcher = p.matcher(content);
        while (matcher.find()) {
            String n = matcher.group(0).toString();
            list.add(n);
        }
        return list;
    }

    /**
     * 从字符串中查找数字字符串
     */
    public static List<String> getNumbers(String content) {
        List<String> digitList = new ArrayList<String>();
        Pattern p = Pattern.compile("(\\d+)");
        Matcher m = p.matcher(content);
        while (m.find()) {
            String find = m.group(1).toString();
            digitList.add(find);
        }


        return digitList;
    }
}
